package config_order.config;

import config_order.bean.Bean1;
import config_order.bean.Bean2;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 描述：
 *
 * @author 🧑 ‍wanwei
 * @since 2022-08-16 16:19
 */
@Component
public class ClassA implements InitializingBean {

	/**
	 * @PostConstruct -> {@link org.springframework.context.annotation.CommonAnnotationBeanPostProcessor}
	 */
	@PostConstruct
	private void init(){
		System.out.println("PostConstruct:" + System.currentTimeMillis());
	}


	@Override
	public void afterPropertiesSet() throws Exception {
		System.out.println("afterPropertiesSet:" + System.currentTimeMillis());
	}


	/**
	 * ww_m @Bean @Compose 这些注解标注的bean 都是由ConfigurationClassPostProcessor 扫描注册的
	 * {@link org.springframework.context.annotation.ConfigurationClassPostProcessor}
	 * {@link org.springframework.context.annotation.ConfigurationClassParser}
	 *
	 * @Bean 注入 会被加载成FactoryBean 进行实例化 实例化方法逻辑就是此方法 方法名就是实例名
	 * @return
	 */
	@Bean
	public Bean1 getBean1(){
		return new Bean1("name","age","type");
	}
}
